public class MyList {
	public static void main(String [] args) {
		//选用合适的构造方法，用你学号前后各两名同学的学号创建四个结点
		Node<Integer> One = new Node<Integer>(20175317,null);
		Node<Integer> Two = new Node<Integer>(20175318,null);
		Node<Integer> Third = new Node<Integer>(20175320,null);
		Node<Integer> Forth = new Node<Integer>(20175321,null);
		
		//把上面四个节点连成一个没有头结点的单链表
		One.next=Two;
		Two.next=Third;
		Third.next=Forth;
		//遍历单链表，打印每个结点的
		Node<Integer> first = One;
		Node<Integer> current = first;
		System.out.println("单链表为：");
		while(current!=null){
			System.out.print(current.toString()+" ");
			current=current.next;
		}
		System.out.println();
		//把你自己插入到合适的位置（学号升序）
		Node<Integer> My = new Node<Integer>(20175319,null);
		current=first;
		if(current.data>My.data){
			first=My;
			My.next=current;
		}
		else {
			while(current.next!=null&&current.next.data<My.data){
				current=current.next;
			}
			My.next=current.next;
			current.next=My;
		}
		//遍历单链表，打印每个结点的
		current = first;
		System.out.println("插入学号后单链表为：");
		while(current!=null){
			System.out.print(current.toString()+" ");
			current=current.next;
		}
		System.out.println();
		//从链表中删除自己
		current=first;
		if(current.data.equals(My.data)){//成为头结点
			first=current.next;
		}
		else {
			while(current.next!=null&&!current.next.data.equals(My.data)){
				current=current.next;
			}
			current.next=current.next.next;
		}
		//遍历单链表，打印每个结点的
		current = first;
		System.out.println("删除学号后单链表为：");
		while(current!=null){
			System.out.print(current.toString()+" ");
			current=current.next;
		}
		System.out.println();
	}
}
